package forward.Module.Modules.Misc;

import forward.Client;
import forward.Module.Module;
import forward.Module.ModuleType;

import forward.Module.Modules.Render.TargetHUD;
import forward.Util.WorldRenderUtils;
import forward.api.Value.Mode;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

public class Teams extends Module {
	public static Mode<Enum> mode = new Mode("Mode", "Mode", (Enum[]) TeamsMode.values(), (Enum) TeamsMode.ByWearing);

	public Teams() {
		super("Teams", new String[]{}, ModuleType.Misc);
		this.addValues(mode);
	}

	public static boolean isOnSameTeam(EntityPlayer entity) {
		if (!Client.instance.getModuleManager().getModuleByClass(Teams.class).isEnabled()){
			return false;
		}
		if (mode.getValue()==TeamsMode.ByWearing) {
			if (Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3] != null && entity.inventory.armorInventory[3] != null) {
				ItemStack myHead = Minecraft.getMinecraft().thePlayer.inventory.armorInventory[3];
				ItemArmor myItemArmor = (ItemArmor) myHead.getItem();

				ItemStack entityHead = entity.inventory.armorInventory[3];
				ItemArmor entityItemArmor = (ItemArmor) myHead.getItem();

				if (myItemArmor.getColor(myHead) == entityItemArmor.getColor(entityHead)) {
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		} else {

			//NotificationManager.show("Module", entity.inventory.armorInventory[0].getDisplayName(), Notification.Type.INFO);
			//boots
			return WorldRenderUtils.getTeamColor(entity) == WorldRenderUtils
					.getTeamColor(Minecraft.getMinecraft().thePlayer);
		}
	}

	enum TeamsMode {
		ByWearing,
		ByColor;
	}
}
